﻿/********************************************************************************
     File:																
            Manager.aspx.cs                         
     Description:
            提案办理情况 管理
     Author:									
            DDBuildTools
            http://DDBuildTools.supesoft.com
     Finish DateTime:
            2013/4/4 0:23:38
     History:
*********************************************************************************/
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using Model;
using Model.Components;
using FrameWork;
using FrameWork.Components;
using FrameWork.WebControls;

namespace Model.Web.Module.Model.TA
{
    public partial class Manager : System.Web.UI.Page
    {
        Int32 IDX = (Int32)Common.sink("IDX", MethodType.Get, 10, 0, DataType.Int);
        string CMD = (string)Common.sink("CMD", MethodType.Get, 10, 1, DataType.Str);
        protected void Page_Load(object sender, EventArgs e)
        {
            FrameWorkPermission.CheckPagePermission(CMD);
            if (!Page.IsPostBack)
            {
                OnStart();
            }
        }
        
        /// <summary>
        /// 开始操作
        /// </summary>
        private void OnStart()
        {
            TAEntity ut = BusinessFacadeModel.TADisp(IDX);
            OnStartData(ut);
            switch (CMD)
            { 
                case "New":
                    TabOptionItem1.Tab_Name = HeadMenuWebControls1.HeadOPTxt = "增加提案办理情况 ";
                    Hidden_Disp();
                    break;
                case "List":
                    TabOptionItem1.Tab_Name = HeadMenuWebControls1.HeadOPTxt = "查看提案办理情况 ";
                    Hidden_Input();
                    Button1.Visible = false;
                    AddEditButton();
                    break;
                case "Edit":
                    TabOptionItem1.Tab_Name = HeadMenuWebControls1.HeadOPTxt = "修改提案办理情况 ";
                    Hidden_Disp();
                    AddDeleteButton();
                    break;
                case "Delete":
                    ut.DataTable_Action_ = DataTable_Action.Delete;
                    if (BusinessFacadeModel.TAInsertUpdateDelete(ut) > 0)
                    {
                        EventMessage.MessageBox(1, "删除成功", string.Format("删除ID:{0}成功!", IDX), Icon_Type.OK, Common.GetHomeBaseUrl("Default.aspx"));
                    }
                    else {
                        EventMessage.MessageBox(1, "删除失败", string.Format("删除ID:{0}失败!", IDX), Icon_Type.Error, Common.GetHomeBaseUrl("Default.aspx"));
                    }
                    break;
                default :
                    EventMessage.MessageBox(2, "不存在操作字符串!", "不存在操作字符串!", Icon_Type.Error, Common.GetHomeBaseUrl("Default.aspx"));
                    break;
            }
        }

        /// <summary>
        /// 增加修改按钮
        /// </summary>
        private void AddEditButton()
        {
            HeadMenuButtonItem bi = new HeadMenuButtonItem();
            bi.ButtonPopedom = PopedomType.Edit;
            bi.ButtonName = " ";
            bi.ButtonUrl = string.Format("?CMD=Edit&IDX={0}", IDX);
            HeadMenuWebControls1.ButtonList.Add(bi);
        }


        /// <summary>
        /// 增加删除按钮
        /// </summary>
        private void AddDeleteButton()
        {
            HeadMenuButtonItem bi = new HeadMenuButtonItem();
            bi.ButtonPopedom = PopedomType.Delete;
            bi.ButtonName = " ";
            bi.ButtonUrlType = UrlType.JavaScript;
            bi.ButtonUrl = string.Format("DelData('?CMD=Delete&IDX={0}')", IDX);
            HeadMenuWebControls1.ButtonList.Add(bi);

            HeadMenuButtonItem bi1 = new HeadMenuButtonItem();
            bi1.ButtonPopedom = PopedomType.List;
            bi1.ButtonIcon = "back.gif";
            bi1.ButtonName = "返回";
            bi1.ButtonUrl = string.Format("?CMD=List&IDX={0}", IDX);
            HeadMenuWebControls1.ButtonList.Add(bi1);
        }

        /// <summary>
        /// 初始化数据
        /// </summary>
        /// <param name="ut"></param>
        private void OnStartData(TAEntity ut)
        {
        a11_Input.Text = a11_Disp.Text = ut.a11.ToString();
                a12_Input.Text = a12_Disp.Text = ut.a12.ToString();
                a21_Input.Text = a21_Disp.Text = ut.a21.ToString();
                a22_Input.Text = a22_Disp.Text = ut.a22.ToString();
                a31_Input.Text = a31_Disp.Text = ut.a31.ToString();
                a32_Input.Text = a32_Disp.Text = ut.a32.ToString();
                b11_Input.Text = b11_Disp.Text = ut.b11.ToString();
                b12_Input.Text = b12_Disp.Text = ut.b12.ToString();
                b21_Input.Text = b21_Disp.Text = ut.b21.ToString();
                b22_Input.Text = b22_Disp.Text = ut.b22.ToString();
                b31_Input.Text = b31_Disp.Text = ut.b31.ToString();
                b32_Input.Text = b32_Disp.Text = ut.b32.ToString();
                c11_Input.Text = c11_Disp.Text = ut.c11.ToString();
                c12_Input.Text = c12_Disp.Text = ut.c12.ToString();
                c21_Input.Text = c21_Disp.Text = ut.c21.ToString();
                c22_Input.Text = c22_Disp.Text = ut.c22.ToString();
                c31_Input.Text = c31_Disp.Text = ut.c31.ToString();
                c32_Input.Text = c32_Disp.Text = ut.c32.ToString();
                d11_Input.Text = d11_Disp.Text = ut.d11.ToString();
                d12_Input.Text = d12_Disp.Text = ut.d12.ToString();
                d21_Input.Text = d21_Disp.Text = ut.d21.ToString();
                d22_Input.Text = d22_Disp.Text = ut.d22.ToString();
                d31_Input.Text = d31_Disp.Text = ut.d31.ToString();
                d32_Input.Text = d32_Disp.Text = ut.d32.ToString();
                d41_Input.Text = d41_Disp.Text = ut.d41.ToString();
                d42_Input.Text = d42_Disp.Text = ut.d42.ToString();
                d51_Input.Text = d51_Disp.Text = ut.d51.ToString();
                d52_Input.Text = d52_Disp.Text = ut.d52.ToString();
                e11_Input.Text = e11_Disp.Text = ut.e11.ToString();
                e12_Input.Text = e12_Disp.Text = ut.e12.ToString();
                e21_Input.Text = e21_Disp.Text = ut.e21.ToString();
                e22_Input.Text = e22_Disp.Text = ut.e22.ToString();
                e31_Input.Text = e31_Disp.Text = ut.e31.ToString();
                e32_Input.Text = e32_Disp.Text = ut.e32.ToString();
                f11_Input.Text = f11_Disp.Text = ut.f11.ToString();
                f12_Input.Text = f12_Disp.Text = ut.f12.ToString();
                j11_Input.Text = j11_Disp.Text = ut.j11.ToString();
                j12_Input.Text = j12_Disp.Text = ut.j12.ToString();
                h11_Input.Text = h11_Disp.Text = ut.h11.ToString();
                h12_Input.Text = h12_Disp.Text = ut.h12.ToString();
                h21_Input.Text = h21_Disp.Text = ut.h21.ToString();
                h22_Input.Text = h22_Disp.Text = ut.h22.ToString();
                dep_Input.Text = dep_Disp.Text = ut.dep.ToString();
                zhuguan_Input.Text = zhuguan_Disp.Text = ut.zhuguan.ToString();
                tj_Input.Text = tj_Disp.Text = ut.tj.ToString();
                
        }

        /// <summary>
        /// 隐藏输入框
        /// </summary>
        private void Hidden_Input()
        {
        a11_Input.Visible = false;
        a12_Input.Visible = false;
        a21_Input.Visible = false;
        a22_Input.Visible = false;
        a31_Input.Visible = false;
        a32_Input.Visible = false;
        b11_Input.Visible = false;
        b12_Input.Visible = false;
        b21_Input.Visible = false;
        b22_Input.Visible = false;
        b31_Input.Visible = false;
        b32_Input.Visible = false;
        c11_Input.Visible = false;
        c12_Input.Visible = false;
        c21_Input.Visible = false;
        c22_Input.Visible = false;
        c31_Input.Visible = false;
        c32_Input.Visible = false;
        d11_Input.Visible = false;
        d12_Input.Visible = false;
        d21_Input.Visible = false;
        d22_Input.Visible = false;
        d31_Input.Visible = false;
        d32_Input.Visible = false;
        d41_Input.Visible = false;
        d42_Input.Visible = false;
        d51_Input.Visible = false;
        d52_Input.Visible = false;
        e11_Input.Visible = false;
        e12_Input.Visible = false;
        e21_Input.Visible = false;
        e22_Input.Visible = false;
        e31_Input.Visible = false;
        e32_Input.Visible = false;
        f11_Input.Visible = false;
        f12_Input.Visible = false;
        j11_Input.Visible = false;
        j12_Input.Visible = false;
        h11_Input.Visible = false;
        h12_Input.Visible = false;
        h21_Input.Visible = false;
        h22_Input.Visible = false;
        dep_Input.Visible = false;
        zhuguan_Input.Visible = false;
        tj_Input.Visible = false;
         
        }

        /// <summary>
        /// 隐藏显示框
        /// </summary>
        private void Hidden_Disp()
        {
        a11_Disp.Visible = false;
        a12_Disp.Visible = false;
        a21_Disp.Visible = false;
        a22_Disp.Visible = false;
        a31_Disp.Visible = false;
        a32_Disp.Visible = false;
        b11_Disp.Visible = false;
        b12_Disp.Visible = false;
        b21_Disp.Visible = false;
        b22_Disp.Visible = false;
        b31_Disp.Visible = false;
        b32_Disp.Visible = false;
        c11_Disp.Visible = false;
        c12_Disp.Visible = false;
        c21_Disp.Visible = false;
        c22_Disp.Visible = false;
        c31_Disp.Visible = false;
        c32_Disp.Visible = false;
        d11_Disp.Visible = false;
        d12_Disp.Visible = false;
        d21_Disp.Visible = false;
        d22_Disp.Visible = false;
        d31_Disp.Visible = false;
        d32_Disp.Visible = false;
        d41_Disp.Visible = false;
        d42_Disp.Visible = false;
        d51_Disp.Visible = false;
        d52_Disp.Visible = false;
        e11_Disp.Visible = false;
        e12_Disp.Visible = false;
        e21_Disp.Visible = false;
        e22_Disp.Visible = false;
        e31_Disp.Visible = false;
        e32_Disp.Visible = false;
        f11_Disp.Visible = false;
        f12_Disp.Visible = false;
        j11_Disp.Visible = false;
        j12_Disp.Visible = false;
        h11_Disp.Visible = false;
        h12_Disp.Visible = false;
        h21_Disp.Visible = false;
        h22_Disp.Visible = false;
        dep_Disp.Visible = false;
        zhuguan_Disp.Visible = false;
        tj_Disp.Visible = false;
      
        }

        /// <summary>
        /// 增加/修改事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Button1_Click(object sender, EventArgs e)
        {
        
            int a11_Value = (int)Common.sink(a11_Input.UniqueID, MethodType.Post, 10, 0, DataType.Int);
            int a12_Value = (int)Common.sink(a12_Input.UniqueID, MethodType.Post, 10, 0, DataType.Int);
            int a21_Value = (int)Common.sink(a21_Input.UniqueID, MethodType.Post, 10, 0, DataType.Int);
            int a22_Value = (int)Common.sink(a22_Input.UniqueID, MethodType.Post, 10, 0, DataType.Int);
            int a31_Value = (int)Common.sink(a31_Input.UniqueID, MethodType.Post, 10, 0, DataType.Int);
            int a32_Value = (int)Common.sink(a32_Input.UniqueID, MethodType.Post, 10, 0, DataType.Int);
            int b11_Value = (int)Common.sink(b11_Input.UniqueID, MethodType.Post, 10, 0, DataType.Int);
            int b12_Value = (int)Common.sink(b12_Input.UniqueID, MethodType.Post, 10, 0, DataType.Int);
            int b21_Value = (int)Common.sink(b21_Input.UniqueID, MethodType.Post, 10, 0, DataType.Int);
            int b22_Value = (int)Common.sink(b22_Input.UniqueID, MethodType.Post, 10, 0, DataType.Int);
            int b31_Value = (int)Common.sink(b31_Input.UniqueID, MethodType.Post, 10, 0, DataType.Int);
            int b32_Value = (int)Common.sink(b32_Input.UniqueID, MethodType.Post, 10, 0, DataType.Int);
            int c11_Value = (int)Common.sink(c11_Input.UniqueID, MethodType.Post, 10, 0, DataType.Int);
            int c12_Value = (int)Common.sink(c12_Input.UniqueID, MethodType.Post, 10, 0, DataType.Int);
            int c21_Value = (int)Common.sink(c21_Input.UniqueID, MethodType.Post, 10, 0, DataType.Int);
            int c22_Value = (int)Common.sink(c22_Input.UniqueID, MethodType.Post, 10, 0, DataType.Int);
            int c31_Value = (int)Common.sink(c31_Input.UniqueID, MethodType.Post, 10, 0, DataType.Int);
            int c32_Value = (int)Common.sink(c32_Input.UniqueID, MethodType.Post, 10, 0, DataType.Int);
            int d11_Value = (int)Common.sink(d11_Input.UniqueID, MethodType.Post, 10, 0, DataType.Int);
            int d12_Value = (int)Common.sink(d12_Input.UniqueID, MethodType.Post, 10, 0, DataType.Int);
            int d21_Value = (int)Common.sink(d21_Input.UniqueID, MethodType.Post, 10, 0, DataType.Int);
            int d22_Value = (int)Common.sink(d22_Input.UniqueID, MethodType.Post, 10, 0, DataType.Int);
            int d31_Value = (int)Common.sink(d31_Input.UniqueID, MethodType.Post, 10, 0, DataType.Int);
            int d32_Value = (int)Common.sink(d32_Input.UniqueID, MethodType.Post, 10, 0, DataType.Int);
            int d41_Value = (int)Common.sink(d41_Input.UniqueID, MethodType.Post, 10, 0, DataType.Int);
            int d42_Value = (int)Common.sink(d42_Input.UniqueID, MethodType.Post, 10, 0, DataType.Int);
            int d51_Value = (int)Common.sink(d51_Input.UniqueID, MethodType.Post, 10, 0, DataType.Int);
            int d52_Value = (int)Common.sink(d52_Input.UniqueID, MethodType.Post, 10, 0, DataType.Int);
            int e11_Value = (int)Common.sink(e11_Input.UniqueID, MethodType.Post, 10, 0, DataType.Int);
            int e12_Value = (int)Common.sink(e12_Input.UniqueID, MethodType.Post, 10, 0, DataType.Int);
            int e21_Value = (int)Common.sink(e21_Input.UniqueID, MethodType.Post, 10, 0, DataType.Int);
            int e22_Value = (int)Common.sink(e22_Input.UniqueID, MethodType.Post, 10, 0, DataType.Int);
            int e31_Value = (int)Common.sink(e31_Input.UniqueID, MethodType.Post, 10, 0, DataType.Int);
            int e32_Value = (int)Common.sink(e32_Input.UniqueID, MethodType.Post, 10, 0, DataType.Int);
            int f11_Value = (int)Common.sink(f11_Input.UniqueID, MethodType.Post, 10, 0, DataType.Int);
            int f12_Value = (int)Common.sink(f12_Input.UniqueID, MethodType.Post, 10, 0, DataType.Int);
            int j11_Value = (int)Common.sink(j11_Input.UniqueID, MethodType.Post, 10, 0, DataType.Int);
            int j12_Value = (int)Common.sink(j12_Input.UniqueID, MethodType.Post, 10, 0, DataType.Int);
            int h11_Value = (int)Common.sink(h11_Input.UniqueID, MethodType.Post, 10, 0, DataType.Int);
            int h12_Value = (int)Common.sink(h12_Input.UniqueID, MethodType.Post, 10, 0, DataType.Int);
            int h21_Value = (int)Common.sink(h21_Input.UniqueID, MethodType.Post, 10, 0, DataType.Int);
            int h22_Value = (int)Common.sink(h22_Input.UniqueID, MethodType.Post, 10, 0, DataType.Int);
            string dep_Value = (string)Common.sink(dep_Input.UniqueID, MethodType.Post, 200, 0, DataType.Str);
            string zhuguan_Value = (string)Common.sink(zhuguan_Input.UniqueID, MethodType.Post, 200, 0, DataType.Str);
            string tj_Value = (string)Common.sink(tj_Input.UniqueID, MethodType.Post, 200, 0, DataType.Str);
            int tjdep_Value = UserData.GetUserDate.U_GroupID;
            DateTime? tjtime_Value = DateTime.Now;
                
            TAEntity ut = BusinessFacadeModel.TADisp(IDX);
            
            ut.a11 = a11_Value;
            ut.a12 = a12_Value;
            ut.a21 = a21_Value;
            ut.a22 = a22_Value;
            ut.a31 = a31_Value;
            ut.a32 = a32_Value;
            ut.b11 = b11_Value;
            ut.b12 = b12_Value;
            ut.b21 = b21_Value;
            ut.b22 = b22_Value;
            ut.b31 = b31_Value;
            ut.b32 = b32_Value;
            ut.c11 = c11_Value;
            ut.c12 = c12_Value;
            ut.c21 = c21_Value;
            ut.c22 = c22_Value;
            ut.c31 = c31_Value;
            ut.c32 = c32_Value;
            ut.d11 = d11_Value;
            ut.d12 = d12_Value;
            ut.d21 = d21_Value;
            ut.d22 = d22_Value;
            ut.d31 = d31_Value;
            ut.d32 = d32_Value;
            ut.d41 = d41_Value;
            ut.d42 = d42_Value;
            ut.d51 = d51_Value;
            ut.d52 = d52_Value;
            ut.e11 = e11_Value;
            ut.e12 = e12_Value;
            ut.e21 = e21_Value;
            ut.e22 = e22_Value;
            ut.e31 = e31_Value;
            ut.e32 = e32_Value;
            ut.f11 = f11_Value;
            ut.f12 = f12_Value;
            ut.j11 = j11_Value;
            ut.j12 = j12_Value;
            ut.h11 = h11_Value;
            ut.h12 = h12_Value;
            ut.h21 = h21_Value;
            ut.h22 = h22_Value;
            ut.dep = dep_Value;
            ut.zhuguan = zhuguan_Value;
            ut.tj = tj_Value;
            ut.tjdep = tjdep_Value;
            ut.tjtime = tjtime_Value;
            
            if (CMD == "New")
            {
                ut.DataTable_Action_ = DataTable_Action.Insert;
            }
            else if (CMD == "Edit")
            {
                ut.DataTable_Action_ = DataTable_Action.Update;
            }
            else
            {
                EventMessage.MessageBox(2, "不存在操作字符串!", "不存在操作字符串!", Icon_Type.Error, Common.GetHomeBaseUrl("Default.aspx"));
            }
            Int32 rInt = BusinessFacadeModel.TAInsertUpdateDelete(ut);
            if ( rInt> 0)
            {
                string OpTxt = string.Format("增加提案办理情况 成功!(ID:{0})", rInt);
                if (ut.DataTable_Action_ == DataTable_Action.Update)
                    OpTxt = string.Format("修改提案办理情况 成功!(ID:{0})",IDX);
                EventMessage.MessageBox(1, "操作成功", OpTxt, Icon_Type.OK, Common.GetHomeBaseUrl("Default.aspx"));
            }
            else if (rInt == -2)
            {
                EventMessage.MessageBox(1, "操作失败", "操作失败,存在相同的键值(用户名/数据)!", Icon_Type.Alert, Common.GetHomeBaseUrl("Default.aspx"));
            }
            else
            {
                EventMessage.MessageBox(1, "操作失败", string.Format("操作失败,返回值:{0}!", rInt), Icon_Type.Error, Common.GetHomeBaseUrl("Default.aspx"));
            }
        }
    }
}
